'use strict';
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	const db = uniCloud.database(); //代码块为cdb
	let callback = {}
	
	let queryStringParameters = event.queryStringParameters
	const collection = db.collection('notice');
	let res = await collection.where({
			_id: queryStringParameters['_id']
		})
		.get()
	console.log('res.data : ', res.data)
	if (res.data.length == 0) {
		callback = {
			mesg: '获取详情失败！',
			code: 500
		}
	} else {
		callback = {
			mesg: '获取详情成功!',
			code: 200,
			data: res.data[0]
		}
	}
	//返回数据给客户端
	return callback
};
